﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- *
 * Copyright 2021 ThoughtWorks, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * -->

<html>
<head>
    <title>Backup in Progress</title>
    <style type="text/css">
        #header {
            background: url('/go/static/images/bg_header_default.png') repeat-x 0 0 transparent;
            color: #FFF;
            font-size: 11px;
            border-bottom: 1px solid #333;
            left: 0;
            position: fixed;
            z-index: 1001;
            right: 0;
            top: 0;
        }

        #header, #body, #footer {
            clear: both;
        }

        #header .header {
            background: #333333; /* Old browsers */
            /* IE9 SVG, needs conditional override of 'filter' to 'none' */
            background: -moz-linear-gradient(top, #333333 0%, #0f0f0f 100%); /* FF3.6+ */
            background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #333333), color-stop(100%, #0f0f0f)); /* Chrome,Safari4+ */
            background: -webkit-linear-gradient(top, #333333 0%, #0f0f0f 100%); /* Chrome10+,Safari5.1+ */
            background: -o-linear-gradient(top, #333333 0%, #0f0f0f 100%); /* Opera 11.10+ */
            background: -ms-linear-gradient(top, #333333 0%, #0f0f0f 100%); /* IE10+ */
            background: linear-gradient(to bottom, #333333 0%, #0f0f0f 100%); /* W3C */
            padding: 5px 15px;
        }

        .header #application_logo {
            background-image: url("/go/static/images/logo_go.png");
            background-position: 0 4px;
            background-repeat: no-repeat;
            float: left;
            height: 35px;
            width: 114px;
        }

        .message {
            margin: 10px;
            float: left;
            font-size: 11px;
            font-weight: 200;
            color: #999;
            font-family: Arial,​ Helvetica,​ sans-serif;
        }

        .clear_float::after {
            clear: both;
            content: ".";
            display: block;
            height: 0;
            visibility: hidden;
        }

    </style>
</head>
<body>
<div id="body_bg">
    <div id="header">
        <div class="header clear_float">
            <a href="#" id="application_logo">&nbsp;</a>

            <div class="message">Go backup in progress. Backup initiated by '<span>%backup_started_by%</span>' on '<span>%backup_initiated_by%</span>'
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    (function () {
        // DOM will be loaded by now

        var url = "/go/is_backup_finished.json";

        function getRequest(url) {
            var xhr = new XMLHttpRequest();
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        _onComplete(xhr);
                    }
                    else {
                        _onError(xhr);
                    }
                }
            }
            xhr.open("GET", url, true);
            xhr.send();
        }

        function _onComplete(xhr) {
            var jsonResponse = JSON.parse(xhr.responseText);
            var isBackingUp = jsonResponse["is_backing_up"];

            if (!isBackingUp) {
                location.reload(true);
            }
        }

        function _onError(xhr) {
            if (xhr.status === 401) {
                window.location = window.location.protocol + '//' + window.location.host + "/go/auth/login";
            }
        }

        window.setInterval(function () {
            getRequest(url);
        }, 10000);
    })();
</script>
</html>
